<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        /*
        继承
        */

        //父类
        function A(name, age) {
            this.name = name;
            this.age = age;
        }
        A.prototype.getName = function() {
            return this.name;
        }
        

        //子类
        function B(name, age, id){
            //结成原来的私有属性
            A.call(this, name, age);
            //新增的私有属性
            this.id = id;
        }
        //继承原型
        function Fn() {}
        Fn.prototype = A.prototype;
        B.prototype = new Fn();

        //新增原型
        B.prototype.constructor = B;
        B.prototype.xx = 10;


        var obj = new A('王靖凯', 25);
        var dawang = new A('站起来', 22);

        var zhuque = new B('朱雀', 66, 111);

        console.log(obj);
        console.log(dawang);
        console.log(zhuque);
    </script>
</body>
</html>